package cn.edu.hatu.bookshop.dao;

import cn.edu.hatu.bookshop.entity.Cart;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface CartMapper {
    @Select("select * from cart")
    List<Cart> getAll();
    @Select("select * from cart where customerId = #{customerId}")
    List<Cart> findByCustomerId(@Param("customerId")int customerId);
    @Delete("delete from cart where customerId = #{customerId}")
    void delByCustomerId(@Param("customerId")int customerId);
    @Select("select * from cart where cartId = #{cartId}")
    Cart findByCartId(@Param("cartId")int cartId);
    @Delete("delete from cart where cartId=#{cartId}")
    void delByCartId(@Param("cartId")int cartId);
    @Insert("insert into cart(customerId,bookId,price,count,name) values(#{cart.customerId},#{cart.bookId},#{cart.price},#{cart.count},#{cart.name})")
    void addCart(@Param("cart")Cart cart);

}
